﻿Imports System.ComponentModel

<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Public Class ucClassMemberList
    Inherits System.Windows.Forms.UserControl


#Region "Designer"
    'Form overrides dispose to clean up the component list.
    <System.Diagnostics.DebuggerNonUserCode()> _
    Protected Overrides Sub Dispose(ByVal disposing As Boolean)
        Try
            If disposing AndAlso components IsNot Nothing Then
                components.Dispose()
            End If
        Finally
            MyBase.Dispose(disposing)
        End Try
    End Sub
    Friend WithEvents ClassMemberId As System.Windows.Forms.DataGridViewTextBoxColumn
    Friend WithEvents SearchCandidateCode As System.Windows.Forms.DataGridViewTextBoxColumn
    Friend WithEvents SearchCandidateCodePVAK As System.Windows.Forms.DataGridViewTextBoxColumn
    Friend WithEvents StudentId As System.Windows.Forms.DataGridViewTextBoxColumn
    Friend WithEvents PassGrade As System.Windows.Forms.DataGridViewTextBoxColumn
    Friend WithEvents isOpen As System.Windows.Forms.DataGridViewTextBoxColumn
    Friend WithEvents Spacer As System.Windows.Forms.DataGridViewTextBoxColumn
    Friend WithEvents ClassId As System.Windows.Forms.DataGridViewTextBoxColumn
    Friend WithEvents StudentLastName As System.Windows.Forms.DataGridViewTextBoxColumn
    Friend WithEvents StudentFirstName As System.Windows.Forms.DataGridViewTextBoxColumn
    Friend WithEvents MemberNumber As System.Windows.Forms.DataGridViewTextBoxColumn
    Friend WithEvents CandidateCode As System.Windows.Forms.DataGridViewTextBoxColumn
    Friend WithEvents IdNumber As System.Windows.Forms.DataGridViewTextBoxColumn
    Friend WithEvents Attend As System.Windows.Forms.DataGridViewCheckBoxColumn
    Friend WithEvents Grade As System.Windows.Forms.DataGridViewTextBoxColumn
    Friend WithEvents GradeDescription As System.Windows.Forms.DataGridViewTextBoxColumn
    Friend WithEvents LessonId As System.Windows.Forms.DataGridViewTextBoxColumn
    Friend WithEvents PeriodID As System.Windows.Forms.DataGridViewTextBoxColumn



    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    <System.Diagnostics.DebuggerStepThrough()> _
    Private Sub InitializeComponent()
        Dim DataGridViewCellStyle1 As System.Windows.Forms.DataGridViewCellStyle = New System.Windows.Forms.DataGridViewCellStyle()
        Dim DataGridViewCellStyle7 As System.Windows.Forms.DataGridViewCellStyle = New System.Windows.Forms.DataGridViewCellStyle()
        Dim DataGridViewCellStyle2 As System.Windows.Forms.DataGridViewCellStyle = New System.Windows.Forms.DataGridViewCellStyle()
        Dim DataGridViewCellStyle3 As System.Windows.Forms.DataGridViewCellStyle = New System.Windows.Forms.DataGridViewCellStyle()
        Dim DataGridViewCellStyle4 As System.Windows.Forms.DataGridViewCellStyle = New System.Windows.Forms.DataGridViewCellStyle()
        Dim DataGridViewCellStyle5 As System.Windows.Forms.DataGridViewCellStyle = New System.Windows.Forms.DataGridViewCellStyle()
        Dim DataGridViewCellStyle6 As System.Windows.Forms.DataGridViewCellStyle = New System.Windows.Forms.DataGridViewCellStyle()
        Me.grdClassMember = New org.codegen.win.controls.Grid.CGSQLGrid()
        Me.ClassMemberId = New System.Windows.Forms.DataGridViewTextBoxColumn()
        Me.SearchCandidateCode = New System.Windows.Forms.DataGridViewTextBoxColumn()
        Me.SearchCandidateCodePVAK = New System.Windows.Forms.DataGridViewTextBoxColumn()
        Me.StudentId = New System.Windows.Forms.DataGridViewTextBoxColumn()
        Me.PassGrade = New System.Windows.Forms.DataGridViewTextBoxColumn()
        Me.isOpen = New System.Windows.Forms.DataGridViewTextBoxColumn()
        Me.Spacer = New System.Windows.Forms.DataGridViewTextBoxColumn()
        Me.ClassId = New System.Windows.Forms.DataGridViewTextBoxColumn()
        Me.StudentLastName = New System.Windows.Forms.DataGridViewTextBoxColumn()
        Me.StudentFirstName = New System.Windows.Forms.DataGridViewTextBoxColumn()
        Me.MemberNumber = New System.Windows.Forms.DataGridViewTextBoxColumn()
        Me.CandidateCode = New System.Windows.Forms.DataGridViewTextBoxColumn()
        Me.IdNumber = New System.Windows.Forms.DataGridViewTextBoxColumn()
        Me.Attend = New System.Windows.Forms.DataGridViewCheckBoxColumn()
        Me.Grade = New System.Windows.Forms.DataGridViewTextBoxColumn()
        Me.GradeDescription = New System.Windows.Forms.DataGridViewTextBoxColumn()
        Me.LessonId = New System.Windows.Forms.DataGridViewTextBoxColumn()
        Me.PeriodID = New System.Windows.Forms.DataGridViewTextBoxColumn()
        CType(Me.grdClassMember, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.SuspendLayout()
        '
        'grdClassMember
        '
        Me.grdClassMember.AllowUserToAddRows = False
        Me.grdClassMember.AllowUserToDeleteRows = False
        Me.grdClassMember.AllowUserToOrderColumns = True
        Me.grdClassMember.AllowUserToResizeRows = False
        DataGridViewCellStyle1.BackColor = System.Drawing.Color.AntiqueWhite
        Me.grdClassMember.AlternatingRowsDefaultCellStyle = DataGridViewCellStyle1
        Me.grdClassMember.BackgroundColor = System.Drawing.SystemColors.Window
        Me.grdClassMember.BindingSource = Nothing
        Me.grdClassMember.CellBorderStyle = System.Windows.Forms.DataGridViewCellBorderStyle.SingleHorizontal
        Me.grdClassMember.ColumnIndexToHide = 0
        Me.grdClassMember.Columns.AddRange(New System.Windows.Forms.DataGridViewColumn() {Me.ClassMemberId, Me.SearchCandidateCode, Me.SearchCandidateCodePVAK, Me.StudentId, Me.PassGrade, Me.isOpen, Me.Spacer, Me.ClassId, Me.StudentLastName, Me.StudentFirstName, Me.MemberNumber, Me.CandidateCode, Me.IdNumber, Me.Attend, Me.Grade, Me.GradeDescription, Me.LessonId, Me.PeriodID})
        Me.grdClassMember.DBMapper = Nothing
        Me.grdClassMember.Dock = System.Windows.Forms.DockStyle.Fill
        Me.grdClassMember.EditMode = System.Windows.Forms.DataGridViewEditMode.EditProgrammatically
        Me.grdClassMember.Font = New System.Drawing.Font("Tahoma", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.grdClassMember.gpEditForm = "Forms.Edit.frmClassMemberDetails"
        Me.grdClassMember.gpKeyColumnName = "ClassMemberId"
        Me.grdClassMember.gpSelectFields = "*"
        Me.grdClassMember.gpSelectFrom = "vClassMember"
        Me.grdClassMember.gpSortColumn = "StudentFirstName"
        Me.grdClassMember.gpSortDirection = System.ComponentModel.ListSortDirection.Ascending
        Me.grdClassMember.gpWhereclause = "                "
        Me.grdClassMember.GridColor = System.Drawing.SystemColors.Control
        Me.grdClassMember.GridColumnProvider = Nothing
        Me.grdClassMember.isLocalizable = False
        Me.grdClassMember.lastLoadedSQL = ""
        Me.grdClassMember.Location = New System.Drawing.Point(0, 0)
        Me.grdClassMember.Name = "grdClassMember"
        Me.grdClassMember.ReadOnly = True
        DataGridViewCellStyle7.BackColor = System.Drawing.SystemColors.Desktop
        DataGridViewCellStyle7.Font = New System.Drawing.Font("Tahoma", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        DataGridViewCellStyle7.ForeColor = System.Drawing.SystemColors.WindowText
        DataGridViewCellStyle7.SelectionBackColor = System.Drawing.SystemColors.Highlight
        DataGridViewCellStyle7.SelectionForeColor = System.Drawing.SystemColors.HighlightText
        Me.grdClassMember.RowHeadersDefaultCellStyle = DataGridViewCellStyle7
        Me.grdClassMember.RowHeadersVisible = False
        Me.grdClassMember.RowTemplate.Height = 20
        Me.grdClassMember.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect
        Me.grdClassMember.SelectSQLStatement = Nothing
        Me.grdClassMember.Size = New System.Drawing.Size(900, 517)
        Me.grdClassMember.TabIndex = 0
        '
        'ClassMemberId
        '
        Me.ClassMemberId.DataPropertyName = "ClassMemberId"
        DataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.TopRight
        Me.ClassMemberId.DefaultCellStyle = DataGridViewCellStyle2
        Me.ClassMemberId.HeaderText = "ClassMemberId"
        Me.ClassMemberId.Name = "ClassMemberId"
        Me.ClassMemberId.ReadOnly = True
        Me.ClassMemberId.Visible = False
        Me.ClassMemberId.Width = 50
        '
        'SearchCandidateCode
        '
        Me.SearchCandidateCode.DataPropertyName = "SearchCandidateCode"
        Me.SearchCandidateCode.HeaderText = "SearchCandidateCode"
        Me.SearchCandidateCode.Name = "SearchCandidateCode"
        Me.SearchCandidateCode.ReadOnly = True
        Me.SearchCandidateCode.Visible = False
        '
        'SearchCandidateCodePVAK
        '
        Me.SearchCandidateCodePVAK.HeaderText = "SearchCandidateCodePVAK"
        Me.SearchCandidateCodePVAK.DataPropertyName = "SearchCandidateCodePVAK"
        Me.SearchCandidateCodePVAK.Name = "SearchCandidateCodePVAK"
        Me.SearchCandidateCodePVAK.ReadOnly = True
        Me.SearchCandidateCodePVAK.Visible = False
        '
        'StudentId
        '
        Me.StudentId.DataPropertyName = "StudentId"
        Me.StudentId.HeaderText = "StudentId"
        Me.StudentId.Name = "StudentId"
        Me.StudentId.ReadOnly = True
        Me.StudentId.Visible = False
        '
        'PassGrade
        '
        Me.PassGrade.DataPropertyName = "PassGrade"
        Me.PassGrade.HeaderText = "PassGrade"
        Me.PassGrade.Name = "PassGrade"
        Me.PassGrade.ReadOnly = True
        Me.PassGrade.Visible = False
        '
        'isOpen
        '
        Me.isOpen.DataPropertyName = "isOpen"
        Me.isOpen.HeaderText = "isOpen"
        Me.isOpen.Name = "isOpen"
        Me.isOpen.ReadOnly = True
        Me.isOpen.Visible = False
        '
        'Spacer
        '
        Me.Spacer.HeaderText = "..."
        Me.Spacer.Name = "Spacer"
        Me.Spacer.ReadOnly = True
        Me.Spacer.Width = 15
        '
        'ClassId
        '
        Me.ClassId.DataPropertyName = "ClassId"
        DataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.TopRight
        Me.ClassId.DefaultCellStyle = DataGridViewCellStyle3
        Me.ClassId.HeaderText = "ClassId"
        Me.ClassId.Name = "ClassId"
        Me.ClassId.ReadOnly = True
        Me.ClassId.Visible = False
        Me.ClassId.Width = 50
        '
        'StudentLastName
        '
        Me.StudentLastName.DataPropertyName = "StudentLastName"
        Me.StudentLastName.HeaderText = "Last Name"
        Me.StudentLastName.Name = "StudentLastName"
        Me.StudentLastName.ReadOnly = True
        Me.StudentLastName.Width = 150
        '
        'StudentFirstName
        '
        Me.StudentFirstName.DataPropertyName = "StudentFirstName"
        DataGridViewCellStyle4.Alignment = System.Windows.Forms.DataGridViewContentAlignment.TopLeft
        Me.StudentFirstName.DefaultCellStyle = DataGridViewCellStyle4
        Me.StudentFirstName.HeaderText = "First Name"
        Me.StudentFirstName.Name = "StudentFirstName"
        Me.StudentFirstName.ReadOnly = True
        Me.StudentFirstName.Width = 150
        '
        'MemberNumber
        '
        Me.MemberNumber.DataPropertyName = "MemberNumber"
        Me.MemberNumber.HeaderText = "Member Number"
        Me.MemberNumber.Name = "MemberNumber"
        Me.MemberNumber.ReadOnly = True
        '
        'CandidateCode
        '
        Me.CandidateCode.DataPropertyName = "CandidateCode"
        DataGridViewCellStyle5.Alignment = System.Windows.Forms.DataGridViewContentAlignment.TopLeft
        Me.CandidateCode.DefaultCellStyle = DataGridViewCellStyle5
        Me.CandidateCode.HeaderText = "Candidate Code"
        Me.CandidateCode.Name = "CandidateCode"
        Me.CandidateCode.ReadOnly = True
        Me.CandidateCode.Width = 150
        '
        'IdNumber
        '
        Me.IdNumber.DataPropertyName = "IdNumber"
        Me.IdNumber.HeaderText = "Αρ. Ταυτότητας"
        Me.IdNumber.Name = "IdNumber"
        Me.IdNumber.ReadOnly = True
        Me.IdNumber.Visible = False
        '
        'Attend
        '
        Me.Attend.DataPropertyName = "Attend"
        Me.Attend.FalseValue = "0"
        Me.Attend.HeaderText = "Attend"
        Me.Attend.Name = "Attend"
        Me.Attend.ReadOnly = True
        Me.Attend.Resizable = System.Windows.Forms.DataGridViewTriState.[False]
        Me.Attend.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic
        Me.Attend.TrueValue = "1"
        Me.Attend.Visible = False
        '
        'Grade
        '
        Me.Grade.DataPropertyName = "Grade"
        DataGridViewCellStyle6.Alignment = System.Windows.Forms.DataGridViewContentAlignment.TopRight
        Me.Grade.DefaultCellStyle = DataGridViewCellStyle6
        Me.Grade.HeaderText = "Grade"
        Me.Grade.Name = "Grade"
        Me.Grade.ReadOnly = True
        Me.Grade.Width = 80
        '
        'GradeDescription
        '
        Me.GradeDescription.HeaderText = "Result"
        Me.GradeDescription.Name = "GradeDescription"
        Me.GradeDescription.ReadOnly = True
        '
        'LessonId
        '
        Me.LessonId.DataPropertyName = "LessonId"
        Me.LessonId.HeaderText = "LessonId"
        Me.LessonId.Name = "LessonId"
        Me.LessonId.ReadOnly = True
        Me.LessonId.Visible = False
        '
        'PeriodID
        '
        Me.PeriodID.DataPropertyName = "PeriodId"
        Me.PeriodID.HeaderText = "PeriodID"
        Me.PeriodID.Name = "PeriodID"
        Me.PeriodID.ReadOnly = True
        Me.PeriodID.Visible = False
        '
        'ucClassMemberList
        '
        Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
        Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
        Me.Controls.Add(Me.grdClassMember)
        Me.Name = "ucClassMemberList"
        Me.Size = New System.Drawing.Size(900, 517)
        CType(Me.grdClassMember, System.ComponentModel.ISupportInitialize).EndInit()
        Me.ResumeLayout(False)

    End Sub

    Public WithEvents grdClassMember As org.codegen.win.controls.Grid.CGSQLGrid


#End Region

#Region "Standard Code"

    Private Const STR_GRADE As String = "Grade"
    Private Const STR_LESSON_ID As String = "LessonId"
    Private Const STR_CLASS_ID As String = "ClassId"

    Private Const STR_PASS_GRADE As String = "PassGrade"
    Private Const STR_GRADE_DESCRIPTION As String = "GradeDescription"

    Private LESSON_ID_COL As Integer = -1
    Private GRADE_COL As Integer = -1

    Private Sub ucListClassMember_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        If Me.DesignMode Then Exit Sub
        Me.setColumnDataSources()
        Me.gridViewCellGradeValidator = New StudentGradeGridViewValidator(Me.grdClassMember)

        LESSON_ID_COL = Me.grdClassMember.Columns(STR_LESSON_ID).Index
        GRADE_COL = Me.grdClassMember.Columns(STR_GRADE).Index

    End Sub

    'use this method to assign datasources to columns that are combo boxes!
    Protected Sub setColumnDataSources()

        If Me.DesignMode Then Exit Sub

    End Sub


#End Region

    Private gridViewCellGradeValidator As StudentGradeGridViewValidator

    Private Sub GridDataLoaded(ByVal sender As Grid.CGBaseGrid) _
                                         Handles grdClassMember.GridDataLoaded

        For idx As Integer = 0 To Me.grdClassMember.Rows.Count - 1
            Call setGradeDescription(GRADE_COL, idx)

        Next

    End Sub

    Private Sub setRowBackcolor(ByVal rowIndex As Integer, _
                                ByVal grade As Integer, _
                                 ByVal lessonPassGrade As Integer)

        If grade >= lessonPassGrade Then
            'success
            Me.grdClassMember.Rows(rowIndex).DefaultCellStyle.BackColor = Color.LightYellow
        Else
            'failure
            Me.grdClassMember.Rows(rowIndex).DefaultCellStyle.BackColor = Color.LightSalmon

        End If

    End Sub
    Private Sub setGradeDescription(ByVal columnIndex As Integer, ByVal rowIndex As Integer)

        If rowIndex <= -1 Then Return

        If columnIndex = LESSON_ID_COL Or _
                    columnIndex = GRADE_COL Then

            If IsDBNull(grdClassMember(STR_GRADE, rowIndex).Value) Then
                grdClassMember(STR_GRADE_DESCRIPTION, rowIndex).Value = _
                    DBNull.Value
            Else
                Dim grade As Integer? = CType(grdClassMember(STR_GRADE, rowIndex).Value, Integer?)
                Dim ClassId As Integer? = CType(grdClassMember(STR_CLASS_ID, rowIndex).Value, Integer?)
                Dim passGrade As Integer? = CType(grdClassMember(STR_PASS_GRADE, rowIndex).Value, Integer?)

                grdClassMember(STR_GRADE_DESCRIPTION, rowIndex).Value = _
                        GradeMappingUtils.getGradeDescription(ClassId, grade)

                Call setRowBackcolor(rowIndex, grade.GetValueOrDefault, passGrade.GetValueOrDefault)
            End If
        End If
    End Sub

    Private Sub CellValueChanged(ByVal sender As Object, _
                                 ByVal e As DataGridViewCellEventArgs) _
                             Handles grdClassMember.CellValueChanged
        
        Call setGradeDescription(e.ColumnIndex, e.RowIndex)

    End Sub

   

End Class

